#include <list>
#include <vector>
#include <iostream>
#include "vertex.h"
#include <stdlib.h>
using namespace std;

class FibonacciHeap;

class RootList
{

private:
	FibonacciHeap *min;
	list<FibonacciHeap*> roots;
	vector<FibonacciHeap*> pos;	
	int numNodes;
	void Cascading_Cut(FibonacciHeap *H);
	void Cut(FibonacciHeap *x);
	void meld(RootList h);
	void removeMin();
	FibonacciHeap* link(FibonacciHeap *h1, FibonacciHeap *h2);
public:

        RootList();

	void printHeap();
	void incert(FibonacciHeap c);
	void incertV(Vertex c);
	void decreasekey(FibonacciHeap p, int k);
	void decreasekeyV(Vertex p, int k);
	FibonacciHeap* getMin();
	FibonacciHeap deletemin();
	Vertex deleteminV();
	void printPos();
	bool isEmpty(){return numNodes == 0;};

	int numMeld;
	int numDeletemin;
	int numCut;
};

class FibonacciHeap
{

private:
	int name; //nodo name
	int dist; //distance is the key 


public:	
	bool cut; //flag cut

	FibonacciHeap *parent;
	list<FibonacciHeap*> children;
	//RootList rootList;  
	
public:
	FibonacciHeap();
	FibonacciHeap(int n, int d);	
	int getDist() const { return dist;};		
	void setDist(int d){dist = d;};
	void setName(int n){name = n;};
	void printHeap();
	int getName() const {return name;};
	bool operator==(const FibonacciHeap &p) {
		return (p.getDist() == dist) && (p.getName() == name);
	};
};
